<?php
$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
  $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}
if(isset($_GET['aj'])){
include("ajaxinlcudes.php");
$parentid = $_GET['pid'];
?>
<div id="ptitle">Sub links  &raquo; <?php echo getFieldFromDatabase("content", "page_title", "category_id",$_GET["pid"])?></div>
<?php
}
$re_sublinks = getSubCategoryFind(1,0,"YES");
$row_re_sublinks = mysql_fetch_assoc($re_sublinks);

if($parentid == NULL )
$parentid=0;
$it="";
if(isset($_GET['pid']))
$it="&itemid=".$_GET['pid'];
if(isset($_GET["pid"])){
?>

<form action="?page=category<?php echo $it; ?>" method="post" enctype="multipart/form-data" name="frmcatadd" id="frmcatadd">

    <input type="hidden" name="categoryicon" value="" size="32" />
    <input type="hidden" name="source" value="" size="32" />
    <table align="center" cellpadding="4">
    <tr valign="baseline">
      <td width="95" align="right" nowrap="nowrap">Category name:</td>
      <td width="307"><input type="text" name="categoryname" value="" size="32" /></td>
    </tr>
    <tr valign="baseline">
      <td nowrap="nowrap" align="right">Publish:</td>
      <td><select name="ispublished">
        <option value="yes" <?php if (!(strcmp("yes", ""))) {echo "SELECTED";} ?>>Yes</option>
        <option value="no" <?php if (!(strcmp("no", ""))) {echo "SELECTED";} ?>>No</option>
      </select></td>
    </tr>
    <tr valign="baseline">
      <td nowrap="nowrap" align="right">Order By </td>
      <td>
        <select name="listtype" id="listtype" >
        <?php do { ?>
         <option value="<?php echo $row_re_sublinks["category_id"]; ?>" <?php if (!(strcmp($row_re_sublinks["category_id"], ""))) {echo "SELECTED";} ?>><?php echo $row_re_sublinks["category_name"]; ?></option>
        <?php }while($row_re_sublinks = mysql_fetch_assoc($re_sublinks));?>
        </select>
     </td>
    </tr>

    <tr valign="baseline">
      <td nowrap="nowrap" align="right">Direct link</td>
      <td>
        <input type="checkbox" name="isDirect" id="isDirect" onclick="if(this.checked) showdiv('directlink')
        else hide('directlink');" />{Link page directly to another page}
        <input name="directlink" type="text" id="directlink" value="http://" class="none"/>
      </td>
    </tr>
    <tr valign="baseline">
      <td align="right" valign="top" nowrap="nowrap">Category Description</td>
      <td><textarea name="description" id="pcontent" ></textarea></td>
    </tr>
    <tr valign="baseline">
      <td align="right" valign="top" nowrap="nowrap">Content:</td>
      <td>
        <textarea name="pcontent" id="textarea2" cols="45" rows="5" ></textarea>
          <script language="javascript1.2">
  generate_wysiwyg('textarea2');
</script>   <input type="hidden" name="parentid" id="parentid" value="<?php echo $parentid; ?>" /></td>
    </tr>
    <tr valign="baseline">
      <td nowrap="nowrap" align="right">Allow Comment</td>
      <td><select name="allowcomment">
        <option value="yes" <?php if (!(strcmp(1, ""))) {echo "SELECTED";} ?>>Yes</option>
        <option value="no" <?php if (!(strcmp(0, ""))) {echo "SELECTED";} ?>>No</option>
      </select></td>
    </tr>
    <tr valign="baseline">
      <td nowrap="nowrap" align="right">&nbsp;</td>
      <td><input type="submit" value="Add Category" /></td>
    </tr>
  </table>
  <input type="hidden" name="MM_insert" value="frmcatadd" />
</form>
<?php
}else
{
?>
<style type="text/css">
    #divdetails{display: none;}
</style>
    <?php }?>
